{{ $currentPage := . }}
{{ range .Site.Menus.main.Limit 6 }}
    {{ if .HasChildren }}
        <li class="nav-item col-6 col-lg-auto dropdown">
            <button type="button" class="btn btn-link nav-link dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false" data-bs-display="static">
                {{- .Name | safeHTML -}}
                <span class="visually-hidden">{{ T "menu_btn_toggle" }}</span>
            </button>
            <ul class="dropdown-menu dropdown-menu-lg-start">
                {{ $len := len .Children }}
                {{ range $k, $v := .Children }}
                    {{ if .HasChildren }}
                        <li>
                            <h6 class="dropdown-header"><a class="dropdown-item text-center text-lg-start" href="{{- .PageRef | relLangURL -}}" title="{{ .Name | safeHTML }}">{{ .Name | safeHTML }}</a></h6>
                        </li>
                        <div class="d-flex flex-column flex-lg-row row-gap-lg-2">
                            {{ range .Children }}
                                <li><a class="dropdown-item text-center text-lg-start{{ if $currentPage.IsMenuCurrent .Menu . }} active{{ end }}" href="{{- .PageRef | relLangURL -}}" title="{{ .Name | safeHTML }}">{{ .Name | safeHTML }}</a></li>
                            {{ end }}
                        </div>
                    {{ else }}
                        <li>
                            <a class="dropdown-item{{ if $currentPage.IsMenuCurrent .Menu . }} active{{ end }}" href="{{- .PageRef | relLangURL -}}" title="{{ .Name | safeHTML }}">{{ .Name | safeHTML }}</a>
                        </li>
                    {{ end }}
                    {{ if lt $k (sub $len 1) }}
                        <li><hr class="dropdown-divider"></li>
                    {{ end }}
                {{ end }}
            </ul>
        </li>
    {{ else }}
        <li class="nav-item col-6 col-lg-auto">
            <a class="nav-link{{ if $currentPage.IsMenuCurrent .Menu . }} active{{ end }}" href="{{- .PageRef | relLangURL -}}" title="{{ .Name | safeHTML }}">{{ .Name | safeHTML }}</a>
        </li>
    {{ end }}
{{ end }}